#include "cw_logic_handle.h"

void cw_mode_handle()
{
    u8 buf[2];
    bzero(buf,2);
    buf[0] = get_cw_config_w();
    buf[1] = get_cw_config_cw();
    set_cw_light(buf);
}

void cw_logic_handle(SYS_OPT_KEY opt)
{
    static int time;
    static u8 value;
    if(app_logic_get_last_ssp() != app_logic_get_ssp())//如果是第一次进入
    {
        LOG_INFO("mode_micro_handle\n");
        app_logic_set_last_ssp(app_logic_get_ssp()); //将上次的状态与本次的状态同步
        disp_clear_light();
        disp_clear_cw_light();
        set_custom_recssp(0); //强制复位
        time =arch_os_ms_now();
    }

    if(arch_os_ms_elapsed(time)>=(10)) //10ms轮询一次
    {
        cw_mode_handle(); //cw 色温
    }

    if(opt.oepation == OPT_POWER_TURNOFF) //关机
    {
        app_logic_set_ssp(SSP_POWER_OFF);
    }
    else if (opt.oepation == OPT_PREE_TR)
    {
         add_cw_level(LIGHT_LEVEL);
    }
    else if (opt.oepation == OPT_PREE_TL)
    {
        reduce_cw_level(LIGHT_LEVEL);   
    }
    else if(opt.oepation == OPT_GO_NEXT)
    {
        app_logic_set_ssp(SSP_MODE_SCENE);
    }


}
